function Sprite() {}

Sprite.prototype.init = function(options) {
    this.centerX = options.centerX;
    this.centerY = options.centerY;
    this.radius = options.radius || this.radius;
    this.speed = options.speed || this.speed;
    this.direction = options.direction;
    this.towards = options.towards || options.direction;
}

Sprite.prototype.baseMove = function() {
    if(this.direction === null) {
        return;
    } else if(this.towards === this.direction) {
        switch(this.direction) {
        case "left":
            this.centerX -= this.speed;
            break;
        case "up":
            this.centerY -= this.speed;
            break;
        case "right":
            this.centerX += this.speed;
            break;
        case "down":
            this.centerY += this.speed;
            break;
        default: 
            throw "not reached";
        }
    } else {
        this.towards = this.direction;
    }
}

Sprite.prototype.move = Sprite.prototype.baseMove;

Sprite.prototype.borders = function() {
    return {
        minX:  this.centerX - this.radius,
        maxX: this.centerX + this.radius,
        minY: this.centerY - this.radius,
        maxY: this.centerY + this.radius
    }
}

Sprite.prototype.isIntersecting = function(other) {
    var borders1 = this.borders();
    var borders2 = other.borders();
    return !(borders1.maxY <= borders2.minY
             || borders1.minY >= borders2.maxY
             || borders1.maxX <= borders2.minX
             || borders1.minX >= borders2.maxX);
}
